#include "objectTimer.h"

objectTimer::objectTimer(QWidget *parent)
    : QWidget(parent)
{
    ui.setupUi(this);
	this->setWindowTitle("小九幻灯片_Object");
	this->setWindowIcon(QIcon(":/images/images/Qicon.jpg"));
	ui.imageLabel->setText("点击开始播放小九的裸照");
	QFont ft("微软雅黑", 15);
	ui.imageLabel->setFont(ft);
}

objectTimer::~objectTimer()
{}

void objectTimer::timerEvent(QTimerEvent * event)
{
	if (event->timerId() == this->myTimerID)
	{
		picID++;
		timerStart();
		if (4 == picID)
		{
			picID = 0;
		}
	}
}

void objectTimer::timerStart()
{
	QString strImages = ":/images/images/";
	strImages += QString::number(picID);
	strImages += ".jpg";
	QPixmap pix(strImages);
	ui.imageLabel->setPixmap(pix);
}

void objectTimer::on_startButton_clicked()
{
	this->myTimerID = this->startTimer(TIMEID_START);
	picID = 0;
}

void objectTimer::on_stopButton_clicked()
{
	this->killTimer(this->myTimerID);
	ui.imageLabel->setText("点击开始播放小九的裸照");
	QFont ft("微软雅黑", 15);
	ui.imageLabel->setFont(ft);
}
